#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
typedef struct MyCircularQueue {
    int* p;
    int head;
    int tail;
    int k;
    int size;
}MyCircularQueue;
MyCircularQueue* myCircularQueueCreate(int k) {
    MyCircularQueue* queue = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
    queue->p = (int*)malloc(sizeof(int) * k);
    queue->head = queue->tail = 0;
    queue->k = k;
    queue->size = 0;
    return queue;
}
bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) {
    if (obj->size == obj->k) {
        return false;
    }
    else {
        if (obj->tail == obj->k) {
            obj->tail = 0;
        }
        obj->p[obj->tail++] = value;
        obj->size++;
    }
    return true;
}
bool myCircularQueueDeQueue(MyCircularQueue* obj) {
    if (obj->size == 0) {
        return false;
    }
    else {
        obj->head++;
        if (obj->head == obj->k) {
            obj->head = 0;
        }
        obj->size--;
    }
    return true;
}
int myCircularQueueFront(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj)) {
        return -1;
    }
    return obj->p[obj->head];
}
int myCircularQueueRear(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj)) {
        return -1;
    }
    return obj->p[obj->tail - 1];
}
int myCircularQueueIsEmpty(MyCircularQueue* obj) {
    if (obj->size == 0) {
        return 1;
    }
    return 0;
}
bool myCircularQueueIsFull(MyCircularQueue* obj) {
    return obj->size == obj->k;
}
void myCircularQueueFree(MyCircularQueue* obj) {
    free(obj->p);
    free(obj);
}
void test() {
   
}
int main()
{
    test();
    return 0;
}
